package com.hp.ssm.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hp.ssm.bean.People;
import com.hp.ssm.bean.PeopleExample;
import com.hp.ssm.mapper.PeopleMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PeopleServiceImp implements PeopleService {

    @Resource
    private PeopleMapper mapper;

    @Override
    public PageInfo<People> pageFind(PeopleExample example, Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<People> list=mapper.selectByExample(example);
        PageInfo<People> pageInfo=new PageInfo<People>(list);
        return pageInfo;
    }

    @Override
    public People findByid(Integer pid) {
        return mapper.selectByPrimaryKey(pid);
    }

    @Override
    public int add(People obj) {
        return mapper.insertSelective(obj);
    }

    @Override
    public int update(People obj) {
        return mapper.updateByPrimaryKeySelective(obj);
    }

    @Override
    public int del(Integer pid) {
        return mapper.deleteByPrimaryKey(pid);
    }
}
